package org.jeecg.controller;

import org.jeecg.domain.ServeProvider;
import org.jeecg.mapper.ServeProviderMapper;
import org.jeecg.service.InstitutionProviderService;
import org.jeecg.service.ServeProviderService;
import org.jeecg.utils.Result;
import org.jeecg.domain.InstitutionStaff;
import org.jeecg.domain.dto.InstitutionStaffDto;
import org.jeecg.service.InstitutionStaffService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author: 孟庆磊
 * @Description: TODO
 * @DateTime: 2024/12/26 0026 13:34
 **/
@RestController
@RequestMapping("institution")
public class InstitutionController {
    @Resource
    private InstitutionStaffService institutionStaffService;
    @Resource
    private ServeProviderMapper serveProviderService;
    @PostMapping("list")
    public Result list(InstitutionStaffDto dto){
        return institutionStaffService.getStaffList(dto);
    }
    @PostMapping("update")
    public Result update(InstitutionStaff institutionStaff){
        if (institutionStaff.getStatus()==null){
            institutionStaff.setStatus(0);
        }
        if (institutionStaff.getStatus()==0){
            institutionStaff.setStatus(1);
        }else if (institutionStaff.getStatus()==1){
            institutionStaff.setStatus(0);
        }
        boolean b = institutionStaffService.updateById(institutionStaff);
        if (!b){
            return Result.error("操作失败");
        }
        return Result.success("操作成功");
    }
    @GetMapping("getId/{id}")
    public Result getId(@PathVariable("id") Long id){
        List<ServeProvider> serveProviderList = serveProviderService.getServeProviderList(id);
        return Result.success(serveProviderList);
    }
    @GetMapping("getaId/{id}")
    public Result getaId(@PathVariable Long id){
        InstitutionStaff byId = institutionStaffService.getById(id);
        return Result.success(byId);
    }
    @GetMapping("getInstitutionId/{id}")
    public Result getInstitutionId(@PathVariable Long id){
        InstitutionStaff byId = institutionStaffService.getById(id);
        return Result.success(byId);
    }
}
